package org.kealinghornets.jchuah.buttons;

import android.content.Intent;
import android.support.v7.app.ActionBarActivity;
import android.os.Bundle;
import android.util.Log;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.Toast;


public class Level3Activity extends Level2Activity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_level3);
    }

    public void onLeftButtonPush (View view){
        Log.d("YouLoser", "Loser has pressed a button");
        Toast.makeText(this, "Why even try, loser?", Toast.LENGTH_SHORT).show();
        toggleVisibility(R.id.MidRightStar);

    }

    public void onMidLeftButtonPush (View view){
        Log.d("YouLoser", "Oi you ewok m8");
        Toast.makeText(this, "Wrong button!", Toast.LENGTH_SHORT).show();
        toggleVisibility(R.id.MiddleStar);
        toggleVisibility(R.id.LeftStar);

    }

    public void onMidRightButtonPush (View view){
        Log.d("YouLoser", "MidRightButton Pushed");
        Toast.makeText(this, "I can't believe how stupid that was!", Toast.LENGTH_SHORT).show();
        toggleVisibility(R.id.MidLeftStar);
        toggleVisibility(R.id.LeftStar);
        toggleVisibility(R.id.MidRightStar);

    }

    public void onRightButtonPush (View view){
        Log.d("YouLoser", "Right Button? More like LOSER!");
        Toast.makeText(this, "You will never win, loser. Because you're a loser.", Toast.LENGTH_SHORT).show();
        toggleVisibility(R.id.MiddleStar);
        toggleVisibility(R.id.MidRightStar);
    }

    public void onLoserButtonPush (View view){
        Log.d("YouLoser", "What a moron!");
        toggleVisibility(R.id.RightStar);
        View LeftStar = findViewById(R.id.LeftStar);
        View MidLeftStar = findViewById(R.id.MidLeftStar);
        View MiddleStar = findViewById(R.id.MiddleStar);
        View MidRightStar= findViewById(R.id.MidRightStar);
        View RightStar = findViewById(R.id.RightStar);
        if (LeftStar.getVisibility() == View.INVISIBLE && MidLeftStar.getVisibility() == View.INVISIBLE && MiddleStar.getVisibility() == View.INVISIBLE && MidRightStar.getVisibility() == View.INVISIBLE &&  RightStar.getVisibility() == View.INVISIBLE){
            startActivity(new Intent(this, LoserActivity.class));
        }else{
            Toast.makeText(this, "The button is right. You're still a loser, loser.", Toast.LENGTH_SHORT).show();
            startActivity(new Intent(this, MainActivity.class));
        }

    }

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        // Inflate the menu; this adds items to the action bar if it is present.
        getMenuInflater().inflate(R.menu.menu_level3, menu);
        return true;
    }

    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
        // Handle action bar item clicks here. The action bar will
        // automatically handle clicks on the Home/Up button, so long
        // as you specify a parent activity in AndroidManifest.xml.
        int id = item.getItemId();

        //noinspection SimplifiableIfStatement
        if (id == R.id.action_settings) {
            return true;
        }

        return super.onOptionsItemSelected(item);
    }
}
